package com.neu.af.common.exception;

public class BusinessException extends RuntimeException {
    public static final BusinessException RULE_NOT_FOUND = new BusinessException(504, "未找到对应过滤规则", new Object[0]);
    public static final BusinessException TAG_NOT_FOUND = new BusinessException(504, "未找到对应标签", new Object[0]);
    public static final BusinessException DATASOURECE_INTERUPTED = new BusinessException(504, "数据中断", new Object[0]);
    public static final BusinessException RULE_CONRAINS_OR_CLASS_NULL = new BusinessException(504, "规则匹配字段或报警等级为空", new Object[0]);
    public static final BusinessException UPDATE_FAIL = new BusinessException(504, "规则更新失败", new Object[0]);
    public static final BusinessException INSERT_FAIL = new BusinessException(504, "规则新增失败", new Object[0]);
    public static final BusinessException DELETE_RULE_FAIL = new BusinessException(504, "规则删除失败", new Object[0]);
    public static final BusinessException SEARCH_RULE_NULL = new BusinessException(504, "规则查询为空", new Object[0]);
    public static final BusinessException RULE_DUPILICATED = new BusinessException(504, "插入规则重复", new Object[0]);
    public static final BusinessException ALARM_CLASS_ILLEGAL = new BusinessException(504, "规则报警等级不合法", new Object[0]);
    public static final BusinessException UPDATE_NOT_CHANGE = new BusinessException(504, "无更新", new Object[0]);
    public static final BusinessException SEARCH_ABNORMAL_NULL = new BusinessException(504, "无异常监测点", new Object[0]);
    public static final BusinessException DELETE_TAG_FAIL = new BusinessException(504, "删除监测点失败", new Object[0]);
    public static final BusinessException SEARCH_DESCRIPTOR_FAIL = new BusinessException(504, "获取描述失败或重复添加，请检查tagName输入是否有误", new Object[0]);



    //    public static final BusinessException DATA_NULL_FOUND = new BusinessException(504, "含缺省数据");

    int code;
    String msg;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public BusinessException() {
    }

    public BusinessException(int code, String msg, Object... args) {
        super(String.format(msg, args));
        this.code = code;
        this.msg = String.format(msg, args);
    }

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException newInstance(String msg, Object... args) {
        return new BusinessException(this.code, msg, args);
    }

}
